<#include "../../common/head.html"/>
<#include "../../common/left.html"/>

<#macro content>
<section class="Hui-article-box">
    <nav class="breadcrumb"><i class="Hui-iconfont"></i>
        <a href="/" class="maincolor">首页</a> <span class="c-999 en">&gt;</span>
        <span class="c-666">菜单管理</span> <span class="c-999 en">&gt;</span>
        <span class="c-666">菜单列表</span>
    </nav>
    <div class="Hui-article">
        <article class="cl pd-20">
            <table class="table table-border table-bordered table-bg table-hover">
                <thead>
                <tr>
                    <th scope="col" colspan="8">菜单列表</th>
                </tr>
                <tr class="text-c">
                    <th width="100">ID</th>
                    <th width="100">菜单路径</th>
                    <th width="100">排序</th>
                    <th width="100">别名</th>
                </tr>
                </thead>
                <tbody>
                <#if sysPermExtList?? && sysPermExtList?size gt 0>
                <#list sysPermExtList as t>
                <tr class="text-c">
                    <td>${(t.id)!}</td>
                    <td>${(t.path)!}</td>
                    <td>
                        ${(t.sort)!}
                        <#if t_index gt 0><i class="Hui-iconfont Hui-iconfont-arrow1-top" title="上移一位"></i></#if>
                        <#if (t_index+1) lt sysPermExtList?size><i class="Hui-iconfont Hui-iconfont-arrow1-bottom" title="下移一位"></i></#if>
                    </td>
                    <td>${(t.alias)!}</td>
                </tr>
                </#list>
            </#if>
            </tbody>
            </table>

            <#if page?? && page.data?size gt 0>
            <div id="DataTables_Table_0_wrapper" class="dataTables_wrapper no-footer">
                <#include "../../common/_paginate.html"/>
                <@paginate currentPage=page.index totalPage=page.totalPage pageParam="index"/>
            </div>
        </#if>
        </article>
    </div>
</section>
</#macro>

<#assign css>
<style>
    .Hui-iconfont {
        cursor: pointer;
    }
</style>
</#assign>

<#assign js>
<script type="text/javascript">
    $(function(){
        $('.Hui-iconfont-arrow1-top').click(function(e){
            let id=$(this).parents('td').siblings().first().text().trim();
            $.ajax({
                url:'/core/menu/up',
                type:'post',
                data:{'id':id},
                dataType:'json',
                success:function (json) {
                    if(json.errno==0){
                        layer.msg('操作成功', {icon: 1,time:1000}, function(){
                            window.top.location.reload();
                        });
                    }else{
                        layer.msg(json.msg);
                    }
                }
            });
        });

        $('.Hui-iconfont-arrow1-bottom').click(function(e){
            let id=$(this).parents('td').siblings().first().text().trim();
            $.ajax({
                url:'/core/menu/down',
                type:'post',
                data:{'id':id},
                dataType:'json',
                success:function (json) {
                    if(json.errno==0){
                        layer.msg('操作成功', {icon: 1,time:1000}, function(){
                            window.top.location.reload();
                        });
                    }else{
                        layer.msg(json.msg);
                    }
                }
            });
        });
    });
</script>
</#assign>
<#include "../../common/layout.html"/>